package com.aizuda.boot.modules.business.contract.service.impl;

import com.aizuda.boot.modules.business.contract.entity.EmployeeTableHeaderEntity;
import com.aizuda.boot.modules.business.contract.mapper.EmployeeTableHeaderMapper;
import com.aizuda.boot.modules.business.contract.service.EmployeeTableHeaderService;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeTableHeaderServiceImpl
        extends ServiceImpl<EmployeeTableHeaderMapper, EmployeeTableHeaderEntity>
        implements EmployeeTableHeaderService {
    @Resource
    private EmployeeTableHeaderMapper mapper;
    /**
     * 根据员工ID更新员工表头配置
     *
     * @param employeeId 员工ID
     * @param headers    表头ID列表
     */
    @Override
    public void updateHeadersByEmployeeId(Long employeeId, List<Integer> headers) {
        UpdateWrapper<EmployeeTableHeaderEntity> wrapper = new UpdateWrapper<>();
        wrapper.eq("employee_id", employeeId).set("headers", headers.toString());
        mapper.update(null, wrapper);

    }

    /**
     * 根据员工id查询表头设置
     * @param employeeId
     * @return
     */
    @Override
    public EmployeeTableHeaderEntity getByEmployeeId(Long employeeId) {
        return mapper.selectByEmployeeId(employeeId);
    }
}
